#ifndef DATAEXPORTER_H
#define DATAEXPORTER_H

#include <QObject>
#include <QSqlQueryModel>
#include <QFile>
#include <QTextStream>

class DataExporter : public QObject
{
    Q_OBJECT
public:
    explicit DataExporter(QObject *parent = nullptr);
    // 核心导出方法
    static bool exportToCsv(QSqlQueryModel *model,
                            const QString &fileName,
                            const QString &separator = ",",
                            const QString &textEncoding = "UTF-8");
    // 获取错误信息
    static QString lastError() { return m_lastError; }

private:
    static QString m_lastError;  // 错误信息缓存

    // 数据格式化（处理逗号等特殊字符）
    static QString formatCsvData(const QVariant &data,
                                 const QString &textDelimiter = "\"");
signals:
};

#endif // DATAEXPORTER_H
